﻿@namespace ThingsGateway.Gateway.Razor
@using ThingsGateway.Admin.Application
@using ThingsGateway.Admin.Razor
@using ThingsGateway.Gateway.Application
@inherits ComponentDefault

@if (ValidateEnable)
{
    <ValidateForm Model="Model" OnValidSubmit="ValidSubmit">


        <EditorForm class="p-2" AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=2 LabelWidth=200 Model="Model">

            <FieldItems>
                <EditorItem TValue="string" TModel="Channel">
                    <EditTemplate Context="value">
                        <div class="col-12">
                            <h6>@Localizer["BasicInformation"]</h6>
                        </div>
                    </EditTemplate>
                </EditorItem>
                <EditorItem @bind-Field="@context.Name" Readonly=BatchEditEnable />
                <EditorItem @bind-Field="@context.ChannelType" />
                <EditorItem @bind-Field="@context.Enable" />
                <EditorItem @bind-Field="@context.LogEnable" />

                <EditorItem TValue="string" TModel="Channel">
                    <EditTemplate Context="value">
                        <div class="col-12">
                            <h6>@Localizer["Connection"]</h6>
                        </div>
                    </EditTemplate>
                </EditorItem>

                <EditorItem @bind-Field="@context.RemoteUrl" />
                <EditorItem @bind-Field="@context.BindUrl" />
                <EditorItem @bind-Field="@context.PortName" />
                <EditorItem @bind-Field="@context.BaudRate" />
                <EditorItem @bind-Field="@context.DataBits" />
                <EditorItem @bind-Field="@context.Parity" />
                <EditorItem @bind-Field="@context.StopBits" />
                <EditorItem @bind-Field="@context.DtrEnable" />
                <EditorItem @bind-Field="@context.RtsEnable" />

            </FieldItems>
            <Buttons>
                <Button ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" IsAsync Text=@DefaultLocalizer["Save"] />
            </Buttons>
        </EditorForm>

    </ValidateForm>



}
else

{
    <EditorForm class="p-2" AutoGenerateAllItem="false" RowType=RowType.Inline ItemsPerRow=2 LabelWidth=200 Model="Model">

        <FieldItems>
            <EditorItem TValue="string" TModel="Channel">
                <EditTemplate Context="value">
                    <div class="col-12">
                        <h6>@Localizer["BasicInformation"]</h6>
                    </div>
                </EditTemplate>
            </EditorItem>
            <EditorItem @bind-Field="@context.Name" />
            <EditorItem @bind-Field="@context.ChannelType" />
            <EditorItem @bind-Field="@context.Enable" />
            <EditorItem @bind-Field="@context.LogEnable" />

            <EditorItem TValue="string" TModel="Channel">
                <EditTemplate Context="value">
                    <div class="col-12">
                        <h6>@Localizer["Connection"]</h6>
                    </div>
                </EditTemplate>
            </EditorItem>

            <EditorItem @bind-Field="@context.RemoteUrl" />
            <EditorItem @bind-Field="@context.BindUrl" />
            <EditorItem @bind-Field="@context.PortName" />
            <EditorItem @bind-Field="@context.BaudRate" />
            <EditorItem @bind-Field="@context.DataBits" />
            <EditorItem @bind-Field="@context.Parity" />
            <EditorItem @bind-Field="@context.StopBits" />
            <EditorItem @bind-Field="@context.DtrEnable" />
            <EditorItem @bind-Field="@context.RtsEnable" />

        </FieldItems>

    </EditorForm>

}
